﻿namespace GoodAdmin.Web.Core;


/// <summary>
/// 菜单管理控制器
/// </summary>
[ApiDescriptionSettings("System", Tag = "菜单管理")]
[Route("system/menu")]
public class MenuController: IDynamicApiController
{
    private readonly IMenuService _menuService;


    public MenuController(IMenuService menuService)
	{
        _menuService = menuService;
    }

    /// <summary>
    /// 添加菜单
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("add")]
    [DisplayName("添加菜单")]
    public async Task AddMenu(MenuAddInput input)
    {
        await _menuService.AddMenu(input);
    }

    /// <summary>
    /// 更新菜单
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("update")]
    [DisplayName("更新菜单")]
    public async Task UpdateMenu(MenuUpdateInput input)
    {
        await _menuService.UpdateMenu(input);
    }

    /// <summary>
    /// 删除菜单
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("delete")]
    [DisplayName("删除菜单")]
    public async Task DeleteMenu(MenuDeleteInput input)
    {
        await _menuService.DeleteMenu(input);
    }
    /// <summary>
    /// 获取菜单树
    /// </summary>
    /// <returns></returns>
    [HttpGet("tree")]
    [DisplayName("获取菜单树")]
    public async Task<List<MenuSimpleInfo>> GetMenuTree()
    {
        return await _menuService.GetMenuTree();
    }
    /// <summary>
    /// 获取接口列表
    /// </summary>
    /// <returns></returns>
    [HttpGet("getApiResource")]
    [DisplayName("获取接口列表")]
    public List<ApiResource> GetApiResource()
    {
        return _menuService.GetResource();
    }
}